//
//  ViewController.m
//  iBeaconDemo
//
//  Created by CRY on 17/1/5.
//  Copyright © 2017年 eGova. All rights reserved.
//

#import "ViewController.h"
#import "TTBeaconRegion.h"
#import "TTPointProbabilityMap.h"
#import "AlgorithmManager.h"

@interface ViewController ()<AlgorithmManagerDelegate>

@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (weak, nonatomic) IBOutlet UITextView *textView2;
// UUID输入框
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UITextField *majorTextField;
@property (weak, nonatomic) IBOutlet UITextField *minorTextField;

@property (strong, nonatomic) AlgorithmManager *manager;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.textView.userInteractionEnabled = NO;
    _textField.text = @"975E500D-1DDD-4A5B-8CDA-F97433005858";
    self.manager = [AlgorithmManager manager];
    self.manager.delegate = self;
}

- (void)algorithmManager:(AlgorithmManager *)manager didUpdatePosition:(TTPoint *)point{
    [self presentLog:[NSString stringWithFormat:@"%@", point]];
}

- (IBAction)startTestButton:(UIButton *)sender {
    if (self.manager.isWorking) {
        [self.manager stop];
    }else{
        [self.manager start];
    }
}

#pragma mark - Log Tools
- (NSString *)nameForProximity:(CLProximity)proximity {
    switch (proximity) {
        case CLProximityUnknown:
            return @"Unknown";
            break;
        case CLProximityImmediate:
            return @"Immediate";
            break;
        case CLProximityNear:
            return @"Near";
            break;
        case CLProximityFar:
            return @"Far";
            break;
    }
}

- (void)presentLog:(NSString *)log{
    
    self.textView.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView.text];
}
- (void)presentLog2:(NSString *)log{
    
    self.textView2.text = [NSString stringWithFormat:@"%@\n%@",log,self.textView2.text];
}

- (void)didReceiveMemoryWarning {
    
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
